package com.woshua.radiogroupmodel;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.woshua.radiogroupmodel.radio.AgeSelector;
import com.woshua.radiogroupmodel.radio.Selector;

public class MainActivity extends AppCompatActivity implements Selector.OnSelectorStateListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AgeSelector selectorOne=findViewById(R.id.selector_one);
        selectorOne.setOnSelectorStateListener(this);

        AgeSelector selectorTwo=findViewById(R.id.selector_two);
        selectorTwo.setOnSelectorStateListener(this);

        AgeSelector selectorThree=findViewById(R.id.selector_three);
        selectorThree.setOnSelectorStateListener(this);
    }

    @Override
    public void onStateChange(Selector selector, boolean isSelect) {
        String tag = (String) selector.getTag();
        if (isSelect) {
            Toast.makeText(this, tag + " is selected", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, tag + " is unselected", Toast.LENGTH_SHORT).show();
        }
    }
}
